import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [//一级路由
  {
    path: '/index',
    name: 'index',
    component: () => import('../views/Index.vue'),
    children:[//二级路由
      {
        path: '/index/home',
        name: 'home',
        component: () => import('../views/Index/Home.vue')
      },
      {
        path: '/index/order',
        name: 'order',
        component: () => import('../views/Index/Order.vue')
      },
      {
        path: '/index/mine',
        name: 'mine',
        component: () => import('../views/Index/Mine.vue')
      },
      {
        path: '/index/tuan',
        name: 'tuan',
        component: () => import('../views/Index/Tuan.vue')
      },
      // 二级路由重定向
      {
        path: '/index',
        component: () => import('../views/Index/Home.vue')
      },
      // 404
      {
        path: '*',
        component: () => import('../views/NotFound.vue')
      }
    ]
  },
  // 一级路由重定向
  {
    path: '/',
    component: () => import('../views/Index.vue')
  },
  // 404
  {
    path: '*',
    component: () => import('../views/NotFound.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
